/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DmuPanel.java
 *
 * Created on 05.12.2008, 15:15:43
 */

package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.border.LineBorder;
import util.Util;

/**
 *
 * @author Niki
 */
public class DmuPanel extends javax.swing.JPanel {

    public int id;
    public boolean isHeader = false;
    /** Creates new form DmuPanel */
    public DmuPanel() {
        initComponents();
    }
    public DmuPanel(String dmuName, int id){
        this();
        this.label1.setText(dmuName);
        this.id = id;
    }
    public void setVariables(double efficiency, double distance){
        this.jLabel1.setText(String.valueOf(Util.roundHalfUp(efficiency*100, 1)) + "%");
        this.jLabel2.setText(String.valueOf(Util.truncate(distance*1000, 1)));
    }
    public boolean isChecked(){
        return this.jCheckBox1.isSelected();
    }
    public void setChecked(boolean val){
        this.jCheckBox1.setSelected(val);
    }
    public static DmuPanel getHeaderRow(){
        DmuPanel header = new DmuPanel();
        Color headerBack = new Color(51,153,255);
        header.setBackground(headerBack);
        header.setForeground(Color.WHITE);
        //header.jCheckBox1.setEnabled(false);
        header.jCheckBox1.setBackground(headerBack);
        header.label1.setText("Product Name");
        Font headerFont = new Font("Dialog", Font.BOLD, 12);
        header.label1.setFont(headerFont);
        header.label1.setForeground(Color.WHITE);
        /*header.label2.setFont(headerFont);
        header.label2.setForeground(Color.WHITE);
        header.label2.setText("Color");*/
        header.jLabel1.setForeground(Color.WHITE);
        header.jLabel1.setFont(headerFont);
        header.jLabel2.setForeground(Color.WHITE);
        header.jLabel2.setFont(headerFont);
        header.jLabel1.setText("Efficiency Score");
        header.jLabel2.setText("Distance To Profile");
        header.isHeader = true;
        return header;
    }

    void setColor(Color color) {
        /*for(Component c:this.getComponents()){
            c.setBackground(color);
            c.repaint();
        }
        this.setBackground(color);
        this.repaint();*/
        this.label1.setBackground(color);
        //setBorder(new javax.swing.border.LineBorder(color, 1, true));
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        label1 = new java.awt.Label();
        jCheckBox1 = new javax.swing.JCheckBox();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        setMaximumSize(new java.awt.Dimension(5000, 5000));
        setLayout(new java.awt.GridLayout(1, 4));

        label1.setAlignment(java.awt.Label.CENTER);
        label1.setText("label1");
        add(label1);

        jCheckBox1.setToolTipText("Click to show product in chart.");
        jCheckBox1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jCheckBox1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });
        add(jCheckBox1);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabel1.setText("efficiency ranking");
        jLabel1.setToolTipText("<html>Shows the efficiency scores of each product,<br>compared to one another.</html>");
        jLabel1.setFocusable(false);
        add(jLabel1);

        jLabel2.setText("profile difference");
        jLabel2.setToolTipText("<html>The <b>profile difference</b> gives information on how far/close <br>the product is to your <b>Defined Weight Profile</b>. A high <b>profile difference</b> implies <br>more structural differences than a low one. A <b>profile difference</b> of 0 means that the <br>product fits to your <b>Desired Weight Profile</b>.</html>");
        add(jLabel2);
    }// </editor-fold>//GEN-END:initComponents

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBox1ActionPerformed

    }//GEN-LAST:event_jCheckBox1ActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private java.awt.Label label1;
    // End of variables declaration//GEN-END:variables

}
